package itheima.C01_properties;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Map;
import java.util.Objects;
import java.util.Properties;
import java.util.Set;

public class Test {
    public static void main(String[] args) throws IOException {
        //1.创建properties对象
        Properties pro=new Properties();
        //2.存储数据
        pro.setProperty(    "zhangsan","123");
        //2.5加载配置文件
        pro.load(new FileInputStream("day12_properties/src/itheima/C01_properties/users.properties"));
        //3.获取配置文件中的数据
        //键找值
        System.out.println(pro.getProperty("zhangsan"));
        System.out.println(pro.getProperty("lisi"));
        System.out.println(pro.getProperty("admin"));

        System.out.println("----------------------");
        //键值对
        Set<Map.Entry<Object,Object>> entries = pro.entrySet();
        for (Map.Entry<Object , Object> entry : entries) {
            System.out.println(entry.getKey()+"="+entry.getValue());
        }
        System.out.println("----------------------");
        //lambda
        pro.forEach((k,v)-> System.out.println(k+"="+v));
    }
}
